package main

import (
	"fmt"
	"go.uber.org/zap"
	"goFuncServer/api"
	"goFuncServer/global"
	_ "goFuncServer/initialization"
	"goFuncServer/proto"
	"google.golang.org/grpc"
	"log"
	"net"
)

func main() {
	//输出启动日志
	zap.S().Infow(
		"Server启动成功：：：",
		zap.String("Host", global.ApiConfig.Host),
		zap.Int("Port", global.ApiConfig.Port),
	)
	//启动服务
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", global.ApiConfig.Port))
	if err != nil {
		panic(err)
	}
	s := grpc.NewServer()
	proto.RegisterUserServer(s, &api.UserServer{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
